<?php

/***  DOCUMENTATION LAYER

Ceo Unit Testing

Last Update: Sep 2007
	
DESCRIPTION
	testing CEO with SimpleTest unit testing
	
NOTES
		
***/

$_tx0 = microtime();

// load SimpleTest
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');

// load class to be tested
require_once('../php_ceo/base.class.php');

// create test class
class SimpleTestTest extends UnitTestCase 
{
  function setUp()
  {
    $this->debug = 0;
    $this->Base = new CeoBase();
  }
  
  function tearDown()
  {
  }

  function testCx()
  {
    $this->assertTrue(is_object($this->Base), 'base is object');
  } 
  
  function testTx1()
  {
    $this->assertTrue( $this->Base->tx() == 0, 'tx call #1');
  }
  
  function testTx2()
  {
    $this->assertTrue($this->Base->tx() > 0, 'tx call #2');
  }
  
  function testFail()
  {
    if ( $this->debug ) $this->assertTrue(1 == 0, 'deliberate fail');
  }
  
  function testError()
  {
    if ( $this->debug ) trigger_error('we have an error');
  }
}

// run test
$test = &new SimpleTestTest();
$test->run(new HtmlReporter());

// debug
if ( $test->debug ) $test->Base->print_d($test->Base->print_r($test));


// timer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
print "<h6 style='margin:12px 0 4px;'>test '{$test->_label}' complete in $stx s</h6>";
print "<h6 style='margin:4px 0;'>more info on SimpleTest available at <a href='http://simpletest.org/'>http://simpletest.org/</a></h6>";

?>
